package cn.java86.myschool.entity;

/**
 * @author oldliu
 * @since 1.0
 */
//为ajax返回准备的对象，封装Ajax状态
public class AjaxResult {
    //code:0请求正常，500：服务器错误，404，没找到
    //401:没有登录
    private int code=0;
    private String msg;//错误信息
    private Object data;//返回的数据
    public AjaxResult(){

    }

    public AjaxResult(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }
    public AjaxResult(String msg) {
        this.msg = msg;
    }
    public AjaxResult(int code,String msg) {
        this.msg = msg;
        this.code=code;
    }
    public AjaxResult(int code) {
        this.code=code;
    }
    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
    public static AjaxResult success(){
        return new AjaxResult();
    }
    public static AjaxResult success(String msg){
        return new AjaxResult(msg);
    }
    public static AjaxResult error(){
        return new AjaxResult(500);
    }
    public static AjaxResult error(int code,String msg){
        return new AjaxResult(code,msg);
    }
}
